package com.wm.yigongfang.common.jwt;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTCreationException;

import javax.sql.rowset.serial.SerialException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

/**
 * @author zhangPeng
 * @description
 * @date 2021/4/24 22:49
 */
public class JwtUtil {

    public static String createToken(String issuer) throws SerialException {
      try {
        Algorithm algorithm = Algorithm.HMAC256("HSF");
        String token = JWT.create()
            .withIssuer(issuer)
            .sign(algorithm);
        return token;
      } catch (JWTCreationException exception){
        throw new SerialException("系统错误，请稍后再试！");
      }
    }
}
